<!doctype html>
<html>
<head>
<meta charset="utf-8">
<title></title>
<link rel="stylesheet" href="${staticServer}/inc/style/main.css" />
<link rel="stylesheet" href="${staticServer}/inc/style/page.css" />
<link rel="stylesheet" href="${staticServer}/css/work_today.css" />
<link rel="stylesheet" href="${staticServer}/inc/style/date/datepicker.css" />
<link rel="stylesheet" href="${staticServer}/css/consultant_client_tracking.css" />
<link rel="stylesheet" href="${staticServer}/inc/style/date/datepicker.css" />
<link rel="stylesheet" href="${staticServer}/css/consultant_client.css" />
<link rel="stylesheet" href="${staticServer}/css/consultant_client_tracking.css" />
<link rel="stylesheet" href="${staticServer}/css/consultant_student_read.css" />
<script src="${staticServer}/inc/js/jquery.js"></script>
<script src="${staticServer}/inc/js/pageset.js"></script>
<script src="${staticServer}/inc/js/model_resp.js"></script>
<script src="${staticServer}/inc/js/datepicker.js"></script>
<script src="${staticServer}/inc/js/htmlfilter.js"></script>
<script src="${staticServer}/inc/js/submitter.js"></script>
<script src="${staticServer}/inc/js/tips.js"></script>
<script>
var infopad = parent.infopad;

$(function(){
	$("#st_type").val("<#if fromUser??>${fromUser.st_type}</#if>");
	$("#state").val("<#if fromUser??>${fromUser.state}</#if>");
	$("#sp_phone").val(${phone});
	$("#st_type").val(${st_type});
	$("#state").val('${state}');
	$("#enddate").val('${endTime}');
	$("#stardate").val('${startTime}');
	$("#types").val('${type}');

});

function del_answers( id )
{
	jconfirm( "确定要删除该提交问卷结果吗？<br><br><span style='color:#c30;'><b>提醒</b>：删除后将无法恢复</span>", "删除确认", function(
			r )
	{
		if( r )
		{
			// 预约信息列表中当前行
			submitter.post( "deleteWenjuanById.json", {
				id: id
			}, function( d )
			{
				window.location.href="from_user_list.htm";
			}, "json" );
		}
	} );
}

function starquery(type)
{
	if(type==0)
	{
		var phone = $( '#sp_phone' ).val();
		var st_type = $( '#st_type' ).val();
		var state = $( '#state' ).val();
		var startTime = $( '#stardate' ).val();
		var endTime = $( '#enddate' ).val();
		var types =   $('#types  option:selected').text();
		if (types=="--请选择分类--"){
            types ="";
		}
        window.location.href=encodeURI("${contextPath}/admin/from_user_list.htm?phone="+phone+"&st_type="+st_type+"&state="+state+"&startTime="+startTime+"&endTime="+endTime+"&type="+types);
	}
	else
	{
		location.href = "?";
	}
}

$(function(){
	//全选按钮 
	$("#allChecked").click(function(){
		if($(this).is(':checked')==true){
			$("#datas td input[type=checkbox]").prop("checked","true");
		}else{
			$("#datas td input[type=checkbox]").prop("checked",false);
		}
	});

});

var deleteClient = function(){
	var $obj = $("#datas td input[type=checkbox]:checked");
	if($obj.length == 0){
		alert("请至少选择一条记录");
		return ;
	}
	if(confirm("确定标记无效？标记无效后无法恢复。")){
		var ids = '';
		for(var i = 0;i<$obj.length;i++){
			if(i == $obj.length-1){
				ids += $($obj[i]).val();
			}else{
				ids += $($obj[i]).val()+",";
			}
		}
		var url = "${contextPath}/admin/deleteFromUserById.json";
    	$.post(url, {"ids":ids}, 
			function(ms) {
	 			if(ms.msg != null){
	 				if(ms.msg == "1"){
	 					alert("标记无效成功!");
	 					setTimeout(function(){
	 						location.reload(); 
						},1200);
	 				}else{
	 					alert("抱歉，系统忙");
	 				}
	 			}else{
	 				alert("抱歉，系统忙");
	 			}
    	});
    };
}
</script>
 <script>
 function uploadToExcel() {
            var phone = $( '#sp_phone' ).val();
			var st_type = $( '#st_type' ).val();
			var state = $( '#state' ).val();
			var startTime = $( '#stardate' ).val();
			var endTime = $( '#enddate' ).val();
			var types =   $('#types  option:selected').text();
			if (types=="--请选择分类--"){
         	   types ="";
			}
            if (startTime == "") {
                infopad.err("开始时间不能为空");
                return;
            }else{
            	infopad.err("正在下载，请稍等!");
            }
            $.post('${contextPath}/admin/wenjuanXz.json', {
                phone: phone,
                st_type: st_type,
                startTime: startTime,
                endTime: endTime,
                types: types,
                state:state,
            }, function (data) {
                if (data) {
                    if (data.name != null) {
                        window.location.href = "http://120.55.241.58//mydata/uploadtea/xls/" + data.name;
                    }
                }
            });
        }

    </script>

</head>

<body>
	<div id="home_link">
		<ul>
			<li></li>
			<li>&gt;</li>
			<li>资源统计管理</li>
			<li>&gt;</li>
			<li class="current">表单资源分配</li>
		</ul>
	</div>
	<div id="container">
		<div id="title">红色表示重复资源，紫色表示无效资源，蓝色表示重复加无效资源。</div>
		<div class="fieldset_container">
			<fieldset>
				<legend>查询条件</legend>
				<ul>
					<li><label>电话号码：</label>
						<input type="text" id="sp_phone" size="15" placeholder="电话号码" value="" />
					</li>
					<li><label>是否有效：</label>
						<select id="st_type">
							<option value="">全部资源</option>
							<option value="1">有效资源</option>
							<option value="2">无效资源</option>
						</select>
					</li>
                    <li>
						<label>分类：</label>
                        <select id="types">
                            <option value="">--请选择分类--</option>
					<#if types??>
						<#list types as types>
                            <option value="${types.type}">${types.type}</option>
						</#list>
					</#if>

                        </select>
                    </li>
					<li><label>是否分配：</label>
						<select id="state">
							<option value="">全部资源</option>
							<option value="1">已分配</option>
							<option value="2">未分配</option>
						</select>
					</li>
					<li><label>起止日期：</label>
						<input type="text" id="stardate" size="13" rel="DATE::Y-m-d" value="${startTime}" />-
						<input type="text" id="enddate" size="13" rel="DATE::Y-m-d" value="${endTime}" />
					</li>
					<li class="controlbar">
						<input type="button" value=" 查 询 " onclick="starquery(0)" />
						<input type="button" value=" 重 置 " onclick="starquery(1)" />
						<input type="button" value=" 标记无效 " onclick="deleteClient()" />
						 <input type="button" value=" 下 载 " onclick="uploadToExcel()" />
					</li>
				</ul>
			</fieldset>
		</div>
		<table>
			<tr class="fields">
				<th><input name="" type="checkbox" value="" id="allChecked"></th>
				<th>姓名</th>
				<th>年龄</th>
				<th>电话</th>
				<th>城市</th>
				<th>分类</th>
				<th>分配状态</th>
				<th>来源网址</th>
				<th>IP地址</th>
				<th>提交时间</th>
				<th>操作</th>
			</tr>

		<tbody id="datas">
		<#if list??>
			<#list list as list>
			<tr <#if list.from_cn gt 0 && list.st_type=="2">style="color:#2D88A8"<#elseif list.from_cn gt 0>style="color:red;"<#elseif list.st_type=="2">style="color:#A65BC2"</#if>>
				<td align="center"><input name="" type="checkbox" value="${list.id}"></td>
				<td align="center"><span class="stress">${list.school}</span></td>
				<td align="center">${list.age}</td>
				<td align="center" rel="nohover">
					<a title="电话：${list.phone}-email:${list.email}"><em class="caption">电话：</em><span>${list.phone}</span></a>
				</td>
				<td align="center">${list.city}</td>
				<td align="center">${list.type}</td>
				<td align="center">
					<#if list.username??><span class="stress">${list.nickname}</span><#else>未分配</#if><br/>
				</td>
				<td align="center" title="${list.url}"><#if list.url?length gt 18>${list.url?substring(0,18)}...<#else>${list.url}</#if></td>
				<td align="center">${list.ip}</td>
				<td align="center">  ${list.cDate}  </td>
				<td align="center">
					<!--<a onclick="del_answer(${list.id})" title="删除该提交问卷结果">删除</a> - -->
					<#if list.username??>
						<a href="#" title="将该用户资源分配给指定的咨询师">分配</a>
					<#else>
						<a href="from_user_allot.htm?id=${list.id}" title="将该用户资源分配给指定的咨询师">分配</a>
					</#if>
				</td>
				<!--<td align="center"><a onclick="del_answers(${list.id})" title="删除该提交问卷结果">删除</a></td>-->
			</tr>
			</#list>
		</#if>
		</tbody>
		</table>
	</div>
	<div id="pager">
		<ul id="pagination">
		<#if page??>
		<#if page.pagetotal?? && page.pagetotal!="0">
	<#assign pagetotal = page.pagetotal>
	<#else>
	<#assign pagetotal = 1>
	</#if>
			<#if page.currpage??>
	<#assign currpage = page.currpage>
	<#else>
	<#assign currpage = 1>
	</#if>
				<#if currpage==1 >
					<li class="previous-off">上一页</li>
					<#else>
					<li class="previous"><a href="${contextPath}/admin/from_user_list.htm?currPage=${currpage-1}&state=${fromUser.state}&st_type=${fromUser.st_type}&startTime=${startTime}&endTime=${endTime}&phone=${phone}&state=${state}&type=${type}">上一页</a></li>
					</#if>

		<#if pagetotal<=11>
			<#list 1..pagetotal as index_up>
	           <#if currpage==index_up >
	           		<li class="current">${index_up}</li>
	           <#else>
	           		<li><a href="${contextPath}/admin/from_user_list.htm?currPage=${index_up}&state=${fromUser.state}&st_type=${fromUser.st_type}&startTime=${startTime}&endTime=${endTime}&phone=${phone}&type=${type}">${index_up}</a></li>
	           </#if>
			</#list>
		<#else>
			<#if currpage<=8 >
				<#list 1..9 as index_up>
	           	<#if currpage==index_up >
	            	<li class="current">${index_up}</li>
	           	<#else>
	               <li><a href="${contextPath}/admin/from_user_list.htm?currPage=${index_up}&state=${fromUser.state}&st_type=${fromUser.st_type}&startTime=${startTime}&endTime=${endTime}&phone=${phone}&type=${type}">${index_up}</a></li>
	           	</#if>
	           	</#list>
	           	<li>...</li>
	           	<li><a href="${contextPath}/admin/from_user_list.htm?currPage=${pagetotal}&state=${fromUser.state}&st_type=${fromUser.st_type}&startTime=${startTime}&endTime=${endTime}&phone=${phone}&type=${type}">${pagetotal}</a></li>

			<#elseif (currpage>= 9 && currpage<pagetotal-7)  >
				<li><a href="${contextPath}/admin/from_user_list.htm?currPage=1&state=${fromUser.state}&st_type=${fromUser.st_type}&startTime=${startTime}&endTime=${endTime}&phone=${phone}&type=${type}">1</a></li>
				<li>...</li>
				<#list currpage-3..currpage+3 as index_up>
	           	<#if currpage==index_up >
	             <li class="current">${index_up}</li>
	           	<#else>
	               <li><a href="${contextPath}/admin/from_user_list.htm?currPage=${index_up}&state=${fromUser.state}&st_type=${fromUser.st_type}&startTime=${startTime}&endTime=${endTime}">${index_up}&phone=${phone}&type=${type}</a></li>
	           	</#if>
	           	</#list>
				<li>...</li>
	           	<li><a href="${contextPath}/admin/from_user_list.htm?currPage=${pagetotal}&state=${fromUser.state}&st_type=${fromUser.st_type}&startTime=${startTime}&endTime=${endTime}&phone=${phone}&type=${type}">${pagetotal}</a></li>
			<#else>
				<li><a href="${contextPath}/admin/from_user_list.htm?currPage=1&state=${fromUser.state}&st_type=${fromUser.st_type}&startTime=${startTime}&endTime=${endTime}&phone=${phone}&type=${type}">1</a></li>
				<li>...</li>
				<#list pagetotal-8..pagetotal as index_up>
	           	<#if currpage==index_up >
	             <li class="current">${index_up}</li>
	           	<#else>
	               <li><a href="${contextPath}/admin/from_user_list.htm?currPage=${index_up}&state=${fromUser.state}&st_type=${fromUser.st_type}&startTime=${startTime}&endTime=${endTime}&phone=${phone}&type=${type}">${index_up}</a></li>
	           	</#if>
				</#list>  
			</#if>
			
		</#if> 
		<#if currpage==pagetotal >
		 	<li class="previous-off">下一页</li>
		<#else>
			<li class="previous"><a href="${contextPath}/admin/from_user_list.htm?currPage=${currpage+1}&state=${fromUser.state}&st_type=${fromUser.st_type}&startTime=${startTime}&endTime=${endTime}&phone=${phone}&type=${type}">下一页</a></li>
		</#if>
		<li class="pageinfo">共${page.total}条记录</li>
		</#if>
		</ul>
	</div>
	<div class="emptyline"></div>
</body>
</html>